<%= render :partial=>"layouts/header" %>

<% $up_img = image_tag("up-q-light.gif", :alt=>"Conforming thumb-up", :align=>"absmiddle") %>
<% $down_img = image_tag("down-q-light.gif", :alt=>"Conforming thumb-down", :align=>"absmiddle") %>
<% $up_unq_img = image_tag("up-unq-light.gif", :alt=>"Thumb-up", :align=>"absmiddle") %>
<% $down_unq_img = image_tag("down-unq-light.gif", :alt=>"Thumb-down", :align=>"absmiddle") %>
<% $spacer_img = image_tag("spacer.gif", :width=>"14", :height=>"16", :align=>"absmiddle") %>
<% $new_img = image_tag("new-light.gif", :width=>"21", :height=>"16", :align=>"absmiddle") %>	
<% $mail_img = image_tag("mail-light.gif", :width=>"14", :height=>"16", :alt=>"Send e-mail to this user", :align=>"absmiddle") %>	
<% $logo100_img = image_tag("logo-100.gif", :width=>"100", :height=>"100", :alt=>"Orange Stone", :align=>"absmiddle") %>	

<div id="banner">
  <div id="banner_title">
Orange<br>Stone
  </div>
  <div id="logo">
  <%= $logo100_img %>
  </div>
</div>

<div id="main-nav">
<ul>
<li><%= link_to "Home", :controller=>"application", :action=>"index" %></li>
<li><%= link_to "Photos", :controller=>"gallery", :action=>"list" %></li>
<% if logged_in? -%>
<li><%= link_to "Submit a photo", :controller=>"gallery", :action=>"new" %></li>
<% end -%>
<li><%= link_to "Users", :controller=>"account", :action=>"list" %></li>
<li><%= link_to "About", "#" %></li>
</ul>
<div id="current_user">
  <% if logged_in? -%>
    <%=@curuser.full_name%>&nbsp;/&nbsp;<%= link_to "Logout", :controller=>"account", :action=>"logout" %>
  <% else -%>
    Please <%= link_to "Login", :controller=>"account", :action=>"login" %>&nbsp;or&nbsp;<%= link_to "Sign up", :controller=>"account", :action=>"signup" %> yourself to view the photos.
  <% end -%>
</div>
</div>


<% if flash[:notice] -%>
  <div id="notice"><%= flash[:notice] %></div>
<% end -%>

<div id="side-bar">
  <div id="login">
    <% if logged_in? -%>
      <%=@curuser.full_name%>
    <% else -%>
      <% form_tag(:controller=>"account", :action=>"login") do %>
      <div id="login_password">
        <label for="user_login">Login</label>
        <%= text_field :user, :login %>
        <label for="user_password">Password</label>
        <%= password_field :user, :password%>
      </div>
      <p>
      <%= submit_tag "Login" %>
      <% end %>
    <% end -%>
  </div>
</div>

<div id="page">
<!--

	<% if logged_in? %>
		<div id="admin">
			<h2>Admin</h2>
			<ul>
				<li><%= link_to image_tag("images")+" New Album", :controller=>"albums", :action=>"new" %></li>
        <li><%= link_to image_tag("image_add")+" New Photo", :controller=>"gallery", :action=>"new" %></li>
				<li id="image_destroy"><%= link_to image_tag("trash.gif")+" Delete Photo", "#" %></li>
        <%= drop_receiving_element "image_destroy", 
		          :update => "photos", :url => { :controller=>"gallery", :action=>"destroy" },
		          :accept => "photo", :hoverclass => "image_destroy_active",
		          :loading => "Element.show('image_destroy_spinner')",
		          :complete => "Element.hide('image_destroy_spinner')" if logged_in? %>
		    <% if params[:controller] == 'gallery' and params[:action] == 'album' %>
        <li id="image_remove"><%= link_to image_tag("arrow_left")+" Remove Photo from Album", "#" %></li>
        <%= drop_receiving_element "image_remove", 
		          :update => "photos", :url => { :controller=>"albums", :action=>"remove", :album_id => params[:id] },
		          :accept => "photo", :hoverclass => "image_destroy_active",
		          :loading => "Element.show('image_destroy_spinner')",
		          :complete => "Element.hide('image_destroy_spinner')" if logged_in? %>
		     <% end %>
      </ul>
			<div id="image_destroy_spinner" style="display:none;clear:both"><%= image_tag "spinner.gif", :style=>"vertical-align:middle" %> Deleting Photo...</div>
		</div>
  <% end %>

			<div id="albums">
				<h2>Photo Albums</h2>
				<ul>
				  <% Album.find(:all).each do |album| %>
				    <li id="album_<%= album.id %>"><%= render(:partial=>"gallery/album",:locals=>{:album=>album}) %></li>
				    <%= drop_receiving_element "album_#{album.id}", 
				          :update => "album_#{album.id}", :url => { :controller=>"albums", :action=>"add_photo", :album_id=>album },
				          :accept => "photo", :hoverclass => "album-active",
				          :loading => "Element.show('album_spinner')",
				          :complete => "Element.hide('album_spinner')" if logged_in? %>
				    <% if logged_in? && (album.id.to_s == params[:id]) %>
				    <div id="commands">
				      <%= link_to "Edit", :controller=>"albums", :action=>"edit", :id=>album %>
				      <%= link_to "Clear", {:controller=>"albums", :action=>"clear", :id=>album}, 
				        :onclick => "return confirm('Are you sure you want to clear \"#{album.title}\" of all photos?');", 
				        :class => "desctructive" %>
				      <%= link_to "Destroy", {:controller=>"albums", :action=>"destroy", :id=>album}, 
				        :onclick => "return confirm('Are you sure you want to destroy \"#{album.title}\"? THERE IS NO UNDO.');", 
				        :class => "desctructive" %>
				      
				    </div>
				    <% end %> 
				  <% end %>
				  <%= content_tag "li", link_to(image_tag("arrow_left")+" Back to gallery", :controller=>"gallery", :action=>"index") if current_page?(:controller=>"gallery", :action=>"album") %>
				</ul>
				<div id="album_spinner" style="display:none;clear:both"><%= image_tag "spinner.gif", :style=>"vertical-align:middle" %> Adding photo to album...</div>	
			</div>

			<div id="albums">
				<p id="login_link"><%= logged_in? ? @curuser.full_name+" "+link_to("Logout", :controller=>"account", :action=>"logout") : link_to("Login", :controller=>"account", :action=>"login") + link_to("Signup", :controller=>"account", :action=>"signup")%></p>
			</div>
-->
      <%= @content_for_layout %>

      <div style="clear:both"></div>
    </div>

		<div id="footer">
			<p>Powered by <%= mail_to "sunmu_bupt@hotmail.com", "James Sun" %></p>
		</div>

  </body>
</html>